﻿using EntitiesLayer;
using QuidditchWpf;
using QuidditchWpf.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace QuiddichWPF
{
    [System.Windows.Data.ValueConversion(typeof(List<Match>), typeof(List<Match>))]
    class ItemsSourceConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            List<Match> allMatches = value as List<Match>;

            int id = (int)parameter;

            List<Match> selectedMatches = new List<Match>();

            selectedMatches.AddRange(allMatches.Where(m => m.CoupeID == id));

            return selectedMatches;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
